package com.qinge.blog.utils.exception;

import com.qinge.blog.utils.result.ResultCode;

/**
 * @author QDW
 * @date 2022/5/5 10:32
 * @description 服务器运行时错误
 **/
public class ServiceException extends RuntimeException{

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误消息
     */
    private String message;

    public ServiceException() {
        this(ResultCode.COMMON_FAIL);
    }

    public ServiceException(String message) {
        this(999,message);
    }



    public ServiceException(Integer code, String message) {
        super(message);;
        this.code = code;
        this.message = message;
    }

    public ServiceException(ResultCode resultCode){
        this.code=resultCode.getCode();
        this.message=resultCode.getMessage();
    }









    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
